import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

class Student {
    //私有属性name
    private String name = "bit";
    //公有属性age
    public int age = 18;
    //不带参数的构造方法
    public Student(){
        System.out.println("Student()");
    }

    private Student(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String,name)");
    }

    private void eat(){
        System.out.println("i am eat");
    }

    public void sleep(){
        System.out.println("i am pig");
    }

    private void function(String str) {
        System.out.println(str);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}



/**
 * @Author 12629
 * @Description：
 */
//无返回值无参数================================
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(double a,int b);
}

//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}
//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}

//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}
public class Test {

    public static void main(String[] args) {
        HashMap< String,Integer> map = new HashMap<>();
        map.put("宋江",1);
        map.put("诸葛亮",2);
        map.put("张飞",3);
        map.put("关羽",3);
        System.out.println(map);
    }

    public static void main5(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "hello");
        map.put(2, "bit");
        map.put(3, "aello");
        map.put(4, "lambda");

        /*map.forEach(new BiConsumer<Integer, String>() {
            @Override
            public void accept(Integer integer, String s) {
                System.out.println("key: "+integer+" val: "+s);
            }
        });*/

        map.forEach((integer, s) -> System.out.println("key: "+integer+" val: "+s));

    }

    public static void main4(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("hello");
        list.add("bit");
        list.add("lambda");
        /*list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });*/
       /* list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });*/
        list.forEach(s-> System.out.println(s));
        list.sort(((o1, o2) -> o1.compareTo(o2)));
        System.out.println("====");
        list.forEach(s-> System.out.println(s));
    }

    public static void main3(String[] args) {
        //NoParameterReturn noParameterReturn = ()->{return 10;};
        NoParameterReturn noParameterReturn = ()->10;
        int ret = noParameterReturn.test();
        System.out.println(ret);

        OneParameterReturn oneParameterReturn = b -> b+9;
        ret = oneParameterReturn.test(10);
        System.out.println(ret);

        MoreParameterReturn moreParameterReturn = (a,b)->a+b;

        ret = moreParameterReturn.test(10,20);
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        NoParameterNoReturn noParameterNoReturn = ()->System.out.println("test()....");
        noParameterNoReturn.test();
        //OneParameterNoReturn oneParameterNoReturn = (int a)->{System.out.println(a+1);};
        OneParameterNoReturn oneParameterNoReturn =  a -> System.out.println(a+1);
        oneParameterNoReturn.test(10);

        MoreParameterNoReturn moreParameterNoReturn = (a,b)-> System.out.println(a+b);
        moreParameterNoReturn.test(1.0,2);
    }

    public static void main1(String[] args) {
        int common = 10;
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn(){
            @Override
            public void test() {
                //common = 99;
                System.out.println("test()....");
                System.out.println(common);
            }
        };

        noParameterNoReturn.test();

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });

        PriorityQueue<Integer> priorityQueue2 = new PriorityQueue<>((o1,o2)->o1-o2);
    }

    //Class对象 只有一个
    public static void main11(String[] args) {
        Class<?> c1 = null;
        try {
            //                     demo1.Student
            c1 = Class.forName("Student");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Class c2 = Student.class;
        Student student = new Student();
        Class c3 = student.getClass();
        System.out.println(c1.equals(c2));
        System.out.println(c1.equals(c3));
        System.out.println(c2.equals(c3));
    }

}